<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:javascript formName="imageForm" staticJavascript="false" dynamicJavascript="true" method="validateForm" cdata="false" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="CONTENT_LOCALES_COLLECTION_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_IMAGE_NEW_MIMETYPE_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_IMAGE_NEW_SIZE_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_IMAGE_NEW_FILENAME_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_IMAGE_NEW_WIDTH_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_IMAGE_NEW_HEIGHT_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<script type="text/javascript">
    <!--
        function scaleOnChange(theForm) {
        	if(theForm.scale.checked) {
        		theForm.scaleWidth.disabled = false;
        		theForm.scaleHeight.disabled = false;
        	} else {
        		theForm.scaleWidth.disabled = true;
        		theForm.scaleHeight.disabled = true;
        	}
        }
    // -->
</script>
<atleap:content identifier="information" ignore="true" uri="/core/contentResource/image/callCreate"/>
<atleap:messages property="contentResourceAlreadyExists" /><br />
<atleap:messages property="updateFailed" />
<atleap:form action="core/contentResource/image/update" method="POST">
    <c:if test="${sessionScope[pageScope.CONTENT_IMAGE_NEW_MIMETYPE_KEY] != null}">
        <h3><atleap:message key="core.contentResource.form.newResource" /></h3>
        <img src="<atleap:randomLink value="${ctxPath}/servlet/thumbnail/" />" border="0" />
        <table  cellspacing="0" cellpadding="0" border="0" class="modificationTable">
            <tr>
                <th>
                    <div class="readOnlyField">
                        <atleap:message key="core.contentResource.form.size" />:&nbsp;
                    </div>
                </th>
                <td>
                    <c:out value="${sessionScope[pageScope.CONTENT_IMAGE_NEW_SIZE_KEY]}" escapeXml="true" />
					
	           </td>
            </tr>
            <tr>
                <th>
                    <div class="readOnlyField">
                        <atleap:message key="core.contentResource.form.fileName" />:&nbsp;
                    </div>
                </th>
                <td>
                    <c:out value="${sessionScope[pageScope.CONTENT_IMAGE_NEW_FILENAME_KEY]}" escapeXml="true" />
                </td>
            </tr>
            <tr>
                <th>
                    <div class="readOnlyField">
                        <atleap:message key="core.contentResource.form.mimeType" />:&nbsp;
                    </div>
                </th>
                <td>
                    <c:out value="${sessionScope[pageScope.CONTENT_IMAGE_NEW_MIMETYPE_KEY]}" escapeXml="true" />
                </td>
            </tr>
            <tr>
                <th>
                    <div class="readOnlyField">
                        <atleap:message key="core.contentResource.form.width" />:&nbsp;
                    </div>
                </th>
                <td>
                    <c:out value="${sessionScope[pageScope.CONTENT_IMAGE_NEW_WIDTH_KEY]}" escapeXml="true" />
                </td>
            </tr>
            <tr>
                <th>
                    <div class="readOnlyField">
                        <atleap:message key="core.contentResource.form.height" />:&nbsp;
                    </div>
                </th>
                <td>
                    <c:out value="${sessionScope[pageScope.CONTENT_IMAGE_NEW_HEIGHT_KEY]}" escapeXml="true" />
                </td>
            </tr>
        </table>
    </c:if>

    <h3><atleap:message key="core.contentResource.form.currentResource" /></h3>
	<img src="<atleap:randomLink value="${ctxPath}/servlet/thumbnail/?contentResourceId=${requestScope.image.id}" />" border="0" />
    <table cellspacing="0" cellpadding="0" border="0" class="modificationTable">
        <tr>
            <th>
                <div class="readOnlyField">
                    <atleap:message key="core.contentResource.form.size" />:&nbsp;
                </div>
            </th>
            <td>
                <c:out value="${imageForm.size}" escapeXml="true" />
                <html:hidden property="size" />
            </td>
        </tr>
        <tr>
            <th>
                <div class="readOnlyField">
                    <atleap:message key="core.contentResource.form.mimeType" />:&nbsp;
                </div>
            </th>
            <td>
                <c:out value="${imageForm.mimeType}" escapeXml="true" />
                <html:hidden property="mimeType" />
            </td>
        </tr>
        <tr>
            <th>
                <div class="readOnlyField">
                    <atleap:message key="core.contentResource.form.width" />:&nbsp;
                </div>
            </th>
            <td>
                <c:out value="${imageForm.width}" escapeXml="true" />
                <html:hidden property="width" />
            </td>
        </tr>
        <tr>
            <th>
                <div class="readOnlyField">
                    <atleap:message key="core.contentResource.form.height" />:&nbsp;
                </div>
            </th>
            <td>
                <c:out value="${imageForm.height}" escapeXml="true" />
                <html:hidden property="height" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="uri" styleClass="label" key="core.contentResource.form.uri" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="uri" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="altUrl" styleClass="label" key="core.contentResource.form.altUrl" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="altUrl" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" styleId="altUriInput" />
				<a href="javascript:void(0);" title="<atleap:message key="core.commons.buttons.browseLinks" />" onclick="browseInPopup('<atleap:rewriteUrl action="/core/browser/browseContentPages" addLocaleSuffix="false"><atleap:param name="opening" value="true" /></atleap:rewriteUrl>', 'altUriInput', 800, 500); return false;">
					<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/hyperlink.gif" />" title="<atleap:message key="core.commons.buttons.browseLinks" />" alt="<atleap:message key="core.commons.buttons.browseLinks" />"  /></a>
            </td>
        </tr>
        <tr>
			<td colspan="2" align="center">
				<atleap:label property="description" key="core.contentResource.form.description" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						<atleap:message key="core.contentResource.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
                    <%--<html:textarea property="description(${contentLocale.identifier})" />--%>
                    <html:text property="description(${contentLocale.identifier})" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
                </td>
			</tr>
		</atleap:iterator>
        <tr>
            <td colspan="2" align="right" nowrap="nowrap">
				<atleap:label property="scale" styleClass="labelCheckboxImg" key="core.contentResource.form.scale" colon="false" helpTip="true" />
				<html:checkbox styleClass="checkbox" property="scale" onchange="scaleOnChange(this.form);" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="scaleWidth" styleClass="label"  key="core.contentResource.form.scaleWidth" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="scaleWidth" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" disabled="true" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="scaleHeight" styleClass="label"  key="core.contentResource.form.scaleHeight" colon="false" helpTip="true" />
            </th>
            <td>
                <html:text property="scaleHeight" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" disabled="true" />
            </td>
        </tr>
    </table>
    <html:hidden property="id" />
    <html:hidden property="version" />
    <atleap:cancel styleClass="button" type="back"><atleap:message key="core.commons.buttons.back" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.update" /></atleap:submit>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
</atleap:form>
